//
//  GHOrderTableViewCell.m
//  GodHorses
//
//  Created by Mac on 2017/11/17.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLOrderTableViewCell.h"
@interface KLOrderTableViewCell ()

@property(nonatomic, strong) UIImageView                     *goodBanerImageView;
@property(nonatomic, strong) STLabel                         *titleLable;//名字
@property(nonatomic, strong) STLabel                         *numLable;//数量


@end
@implementation KLOrderTableViewCell

+ (CGFloat)CellHeight{
    return 120;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = [UIColor whiteColor];
    
    //商品
    UIView * grayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 120)];
    grayView.backgroundColor  = UIColorFromRGBA(0xf2f2f2);
    [self addSubview:grayView];
    
    self.goodBanerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 90, 90)];
    self.goodBanerImageView.image = [UIImage imageNamed:@"06"];
    [grayView addSubview:self.goodBanerImageView];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.goodBanerImageView.top + 5, UIScreenWidth - 20 - self.goodBanerImageView.right, 35)
                                                text:@"鲜榨大橘子打开了手机读卡老实交代安达市打"
                                           textColor:KL_firstTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.titleLable.numberOfLines = 0;
    [grayView addSubview:self.titleLable];
    
    self.numLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.titleLable.st_bottom + 5, UIScreenWidth - 20 - self.goodBanerImageView.right, 15)
                                               text:@"数量：*2"
                                          textColor:KL_secendTextColor
                                               font:13
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentLeft];
    [grayView addSubview:self.numLable];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.goodBanerImageView.right + 10, self.titleLable.st_bottom , UIScreenWidth - 20 - self.goodBanerImageView.right, 16)
                                                text:@"￥1374"
                                           textColor:KL_redColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentRight];
    self.moneyLable.st_right = UIScreenWidth - 10;
    [grayView addSubview:self.moneyLable];
    
}
//- (void)setModel:(GHOrderGoodModel *)model{
//    _model = model;
//    [self.goodBanerImageView sd_setImageWithURL:[NSURL URLWithString:model.g_img] placeholderImage:GH_placeHoderImage];
//    
//    self.titleLable.text = [NSString stringWithFormat:@"%@ *%@",model.g_name,model.g_num];
//    
//    self.nameLable.text = @"";
//    
//    self.moneyLable.text = [NSString stringWithFormat:@"￥%@",model.total_price];
//}

- (void)setModel:(KLOrderGoodModel *)model{
    _model = model;
    [self.goodBanerImageView sd_setImageWithURL:[NSURL URLWithString:model.exhibition_map] placeholderImage:KL_placeHoderImage];
    
    self.titleLable.text = [NSString stringWithFormat:@"%@",model.goods_name];
    
    self.numLable.text = [NSString stringWithFormat:@"数量:%@",model.goods_num];
    
    CGFloat  moeny;
    if (model.goods_price) {
        moeny = model.goods_price.floatValue * model.goods_num.integerValue;
        self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",moeny];
    }
}
- (void)setShopModel:(KLOrderGoodModel *)shopModel{
    _shopModel = shopModel;
    [self.goodBanerImageView sd_setImageWithURL:[NSURL URLWithString:shopModel.exhibition_map] placeholderImage:KL_placeHoderImage];
    
    self.titleLable.text = [NSString stringWithFormat:@"%@",shopModel.goods_name];
    
    self.numLable.text = [NSString stringWithFormat:@"数量:%@",shopModel.goods_num];
    
    CGFloat  moeny;
    if (shopModel.goods_price) {
        moeny = shopModel.goods_price.floatValue * shopModel.goods_num.integerValue;
        self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",moeny];
    }
}
- (void)setDetailModel:(KLGoodDetailModel *)detailModel{
    _detailModel = detailModel;
    [self.goodBanerImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.cover_map.firstObject] placeholderImage:KL_placeHoderImage];
    
    self.titleLable.text = [NSString stringWithFormat:@"%@",detailModel.goods_name];
    
    
    self.numLable.text = [NSString stringWithFormat:@"数量:%ld",detailModel.num];
    
    CGFloat  moeny;
    if (detailModel.price.length) {
        moeny = detailModel.price.floatValue * detailModel.num;
        self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",moeny];
    }
    if (detailModel.discount_price.length) {
        moeny = detailModel.discount_price.floatValue * detailModel.num;
        self.moneyLable.text = [NSString stringWithFormat:@"￥%0.2f",moeny];
    }
}
@end

